﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace ModernUILogViewer.Converters
{
    class DateFormatConverter : IValueConverter
    {
        public object Convert(object value, Type TargetType, object parameter, CultureInfo culture)
        {
            //string output = String.Empty;
            //string format = (string)parameter;

            //IEnumerable<DateTime> list = (IEnumerable<DateTime>)value;
            //IList<string> listout = new List<string>();

            //if (list != null)
            //{
            //    listout.Add(null);

            //    foreach (DateTime dt in list)
            //    {
            //        listout.Add(dt.Date.ToString(format));
            //    }
            //}

            //return listout;

            string format = (string)parameter;

            if (value != null)
            {
                DateTime dt = (DateTime)value;                
                value = dt != DateTime.MinValue.Date ? dt.Date.ToString(format) : null;
            }

            return value;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
